import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StudentAttendanceDetailVO, StudentAttendanceDetailForm, StudentAttendanceDetailQuery } from '@/api/attendance/student/detail/types';

/**
 * 查询学生考勤明细，一天一条列表
 * @param query
 * @returns {*}
 */

export const listStudentAttendanceDetail = (query?: StudentAttendanceDetailQuery): AxiosPromise<StudentAttendanceDetailVO[]> => {
  return request({
    url: '/attendance/student/detail/list',
    method: 'get',
    params: query
  });
};

export const listStudentAttendanceStat = (query?: StudentAttendanceDetailQuery): AxiosPromise<StudentAttendanceDetailVO[]> => {
  return request({
    url: '/attendance/student/detail/stat',
    method: 'get',
    params: query
  });
};

/**
 * 查询学生考勤明细，一天一条详细
 * @param id
 */
export const getStudentAttendanceDetail = (id: string | number): AxiosPromise<StudentAttendanceDetailVO> => {
  return request({
    url: '/attendance/student/detail/' + id,
    method: 'get'
  });
};

/**
 * 新增学生考勤明细，一天一条
 * @param data
 */
export const addStudentAttendanceDetail = (data: StudentAttendanceDetailForm) => {
  return request({
    url: '/attendance/student/detail',
    method: 'post',
    data: data
  });
};

/**
 * 修改学生考勤明细，一天一条
 * @param data
 */
export const updateStudentAttendanceDetail = (data: StudentAttendanceDetailForm) => {
  return request({
    url: '/attendance/student/detail',
    method: 'put',
    data: data
  });
};

/**
 * 删除学生考勤明细，一天一条
 * @param id
 */
export const delStudentAttendanceDetail = (id: string | number | Array<string | number>) => {
  return request({
    url: '/attendance/student/detail/' + id,
    method: 'delete'
  });
};
